import 'package:flutter/material.dart';

/// 路由类
abstract class IRouter {
  /// 页面跳转
  static Future<T?> push<T extends Object?>(
      BuildContext context, Widget widget) {
    return Navigator.of(context)
        .push<T>(MaterialPageRoute(builder: (BuildContext context) => widget));
  }

  /// 参数：(上下文，返回时携带的参数(可选参数))
  static void pop<T extends Object>(BuildContext context, [T? result]) {
    return Navigator.of(context).pop<T>(result);
  }
}

/// 页面调整
abstract class PageRouter extends IRouter {
  // /// 跳转到Web页面
  // static Future toWebPage(BuildContext context, String url) {
  //   return IRouter.push(context, WebPage(url));
  // }
  //
  // /// 跳转到农场
  // static Future toFarm(BuildContext context, String url) {
  //   return IRouter.push(context, WebPage(url));
  // }

  /// 跳转到农场
  static Future toNormalPage(BuildContext context, Widget widget) {
    return IRouter.push(context, widget);
  }

  /// 跳转到农场
  static void pop(BuildContext context) {
    return IRouter.pop(context);
  }
}
